<?php


namespace XiaoGuai\DataStructure\Forest\ParentTree;


/**
 * 双亲表示法
 * Class ParentTreeForest
 * @package XiaoGuai\DataStructure\Forest\ParentTree
 */
class ParentTreeForest
{

    protected $list = [];

    public function __construct()
    {
        $this->list = [];
    }

    /**
     * 构造树, 双亲表示法
     * @param array $maps [['data' => null, 'parent' => ''], ...]
     */
    public function create($maps = [])
    {
        foreach ($maps as $map) {
            $node = new ParentTreeNode();
            $node->data = $map['data'];
            $node->parent = $map['parent'];
            $this->list[] = $node;
        }
    }
}